package common

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

func ApiReturnSuccess(c *gin.Context, data interface{}) {
	c.JSON(http.StatusOK, gin.H{
		"code": 0,
		"msg":  "ok",
		"data": data,
	})
}

func ApiReturnError(c *gin.Context, msg string) {
	ApiReturnErrorByCode(c, -1, msg)
}

func ApiReturnErrorByCode(c *gin.Context, code int, msg string) {
	c.JSON(http.StatusOK, gin.H{
		"code": code,
		"msg":  msg,
	})
}
